#codng:utf-8
import base64
if __name__ == '__main__':
  source_file = open('structure.png','r')
  temp_s = source_file.read().encode()
  target_file = open('t.png','wb')
  target_file.write(base64.b64decode(temp_s))
  source_file.close()
  target_file.close()

'''
import base64

# 图片转字节
def tu_zi_jie():
    with open('jiu.png','rb') as fp:
        tu = base64.b64encode(fp.read())
    # 生成很长得一串字节流
    print(tu)

# 字节转图片
def zi_tu():
	# 这个就是把上面打印的字节流那过来进行转换图片
	# 因为转换后字符串很长所以我截取了一部分
	b_tu = b'iVBORw0KGgoAAAANS....UhEU'
	tu_b = base64.b64decode(b_tu)
    with open('tu.png', 'wb') as fp:
        fp.write(tu_b)
if __name__ == '__main__':
    tu_zi_jie()
    zi_tu()



'''